package study.exception;

import org.apache.log4j.Logger;
import org.junit.Test;

public class Ex {
	private static Logger logger = Logger.getLogger(Ex.class);

	@Test
	public void testException() {
		try {
			throw new Exception();
		} catch (Exception e) {

			StackTraceElement[] trace = e.getStackTrace();
			System.out.println(trace.length);
			int size = trace.length;
			if (size > 5) {
				size = 5;
			}
			for (int i = 0; i < size; i++)
				logger.warn("\tat " + trace[i]);

			// e.printStackTrace();
		}
	}
}
